RP10

聖心女子大学国際交流学科
2024年秋学期

アジア経済研究所 伊藤成朗

\(P\) valueをなぜ使うか

問い=帰無仮説research question=null hypothesis


政策実施後所得の標本平均値 \(\bar{x}\)=特定の値(たとえば政策実施前所得の平均値 \(\mu\))?
pre-policy mean \(\bar{x}\)=specific value (e.g., pre-policy mean \(\mu\))?


仮説検定は以下の手順を踏んでいると想定していますa hypothesis testing considers the following steps

  1. 母集団から\(n\)個の標本を抽出するsample \(n\) values from population
  2. 標本平均値を計算するcompute a sample mean
  3. 1.と2.を無限大の回数繰り返すrepeat 1. and 2. for infinite times

無限大回数繰り返す(\(\simeq\)何度も標本抽出する)ことで、母集団平均値の分布を描くことができますby sampling infinitely many times, one can draw distribution of population mean

\(P\) valueをなぜ使うか

  • 母集団=政策実施前所得の集合population=a collection of pre-policy incomes
  • 母集団平均値\(\mu\)=不可知、その近似分布=可知←繰り返し抽出population mean=cannot be known, its distribution=can be known←repeated sampling

母集団平均値分布で\(\bar{x}\)が外れ値 ⇒ \(\bar{x}\)\(\mu\)の差が大きい\(\bar{x}\) is an outlier in population mean distribution ⇒ \(\bar{x}-\mu\) is large

\(\bar{x}\)の右部分の面積(=\(p\) value)が小さいan area right of \(\bar{x}\) is small

帰無仮説(政策効果なし)の分布では極端な事象an extreme event under the null dist.

政策効果なしは疑問視(「政策効果あり」)zero policy impact is questioned

null and measured mean

null and measured mean

null and measured mean

null and measured mean

\(P\) valueをなぜ使うか

でも、通常は、母集団からの標本抽出などできませんbut we usually cannot sample from population

  • 入手可能であれば、政策実施前と考えられるデータを使いますif available, use the data that are considered as pre-policy
    • 統御群データcontrol group data

手元にあるデータが唯一の場合if the only data is the one in your hands

  • 標本サイズ\(n\)が大きい場合: で近似できる←中心極限定理(\(n\to\infty\))の漸近近似large \(n\): approximated by normal distribution←central limit theorem(\(n\to\infty\))
  • 標本サイズ\(n\)が小さい場合: small \(n\)
    1. 変数が正規分布に従う場合: を想定if sample \(\sim\) \(N(\mu,\sigma^{2})\): use \(t\) tests
    2. 変数が正規分布に従わない場合: 標本をもっと集めるif the sample is off normality: get more sample

\(P\) valueをなぜ使うか

library(ggplot2)
library(data.table)
set.seed(12345)
alpha <- 1
beta <- 4   
n <- 3
base <- ggplot() + xlim(alpha-1, beta+1)
m2 <- NULL
for (i in 1:5) {
  m1 <- runif(n, min = alpha, max = beta)
  m1 <- data.table(x=m1, y = 0-i/(5*5), z = i)
  m2 <- rbind(m2, m1)
}
m2[, z := factor(z)]
m3 <- m2[, .(mean = mean(x), y = mean(y)), by = z]
g <- base + 
  geom_point(data=m2, aes(x=x, y=y, group = z, shape = z, colour = z)) +
  stat_function(aes(colour = "state 1"), fun = dunif, args = list(alpha, beta), n = 10001) +
  geom_point(data=m3, aes(x=mean, y=y, group = z), shape = 10, colour = "blue") +
  geom_point(data=m3, aes(x=mean, y=0), shape = 10, colour = "blue") +
  theme(
    legend.position = "none"
  )
g <- g + geom_density(data = m3, aes(x=mean))

抽出回数=50で上記Rコードを繰り返します。

抽出1回目

抽出1回目

抽出2回目

抽出2回目

抽出3回目

抽出3回目

抽出4回目

抽出4回目

n=3

n=3

n=10

n=10

n=20

n=20

n=50

n=50

n=500

n=500

確率密度関数density functions

確率密度関数density functions

\(P\) valueをなぜ使うか

特定の確率密度関数=母集団から抽出

中心極限定理
central limit theorem母集団がどんな形状でも、moment generating functionがゼロ近傍で存在すれば、標本平均値の分布は標本サイズが無限大になるにつれて、正規分布に近づいていくfor any population distribution, if the moment generating function exists around the neighbourhood of zero, the sample means start to follow a normal distribution as we increase the sample size

母集団

母集団

\(P\) valueをなぜ使うか

n=3

n=3

n=10

n=10

n=20

n=20

n=50

n=50

n=500

n=500

確率密度関数density functions

確率密度関数density functions

\(P\) valueをなぜ使うか

手元にあるデータが唯一の場合

  • 標本サイズ\(n\)が大きい場合: 正規分布を想定できる
    • 分布の期待値\(\hat{\mu}\)と分散\(\hat{\sigma}^{2}\)は公式がある

\(n\)個の値\(x_{i}\), \(i=1,\dots, n\)が期待値\(\mu\)、分散\(\sigma^{2}\)をもつ同じ(independently, identically distributed, i.i.d.)母集団から無作為抽出されているとき、母集団平均値推計量\(\hat{\mu}\)とその分散\(\hat{\sigma}^{2}\)は下記

\[ \begin{aligned} \E\left[\bar{x}\right] &= \E\left[\frac{x_{1}+\dots+x_{n}}{n}\right],&&\\ &= \frac{1}{n}\E\left[x_{1}+\dots+x_{n}\right], &&\scriptsize{\because \E[a+bx]=a+b\E[x]}\\ &= \frac{1}{n}n\mu, &&\scriptsize{\because \mbox{ }x_{i}\mbox{'s are i.i.d.}}\\ &= \mu. \end{aligned} \] \(\bar{x}\)の期待値=\(\mu\)なので、母集団平均値推計量\(\hat{\mu}=\bar{x}\)とする

\[ \begin{aligned} \NU\left[\bar{x}\right] &= \NU\left[\frac{x_{1}+\dots+x_{n}}{n}\right],&&\\ &= \frac{1}{n^{2}}\NU\left[x_{1}+\dots+x_{n}\right], \quad &&\scriptsize{\because\NU[a+bx]=b^{2}\NU[x]}\\ &= \frac{1}{n^{2}}n\sigma^{2}, \quad &&\scriptsize{\because \mbox{ }x_{i}\mbox{'s are i.i.d.}}\\ &= \frac{\sigma^{2}}{n}.&& \end{aligned} \] \(\sigma^{2}\)は不可知なので、標本分散\(s^{2}_{B}=\frac{sse}{n}\)で代用

\(P\) valueをなぜ使うか

標本分散\(s^{2}_{B}\)は期待値が母集団分散と異なる(biased estimatorといいます) \[ \begin{aligned} \E\left[s^{2}_{B}\right] &= \E\left[ \frac{1}{n} \sum_{i=1}^{n} \left(x_{i} - \bar{x}\right)^{2} \right]= \E\left[ \frac{1}{n} \sum_{i=1}^{n} \left(x_{i} - \frac{1}{n} \sum_{j=1}^{n} x_{j} \right)^{2} \right] \\ &= \frac{1}{n} \sum_{i=1}^{n} \E\left[ x_{i}^{2} - \frac{2}{n} x_{i} \sum_{j=1}^{n} x_{j} + \frac{1}{n^2} \sum_{j=1}^{n} x_{j} \sum_{k=1}^{n} x_{k} \right] \\ &= \frac{1}{n} \sum_{i=1}^{n}\left( \E\left[x_{i}^{2}\right] - \frac{2}{n} \left( \sum_{j \neq i} \E\left[x_{i} x_{j}\right] + \E\left[x_{i}^{2}\right] \right) + \frac{1}{n^2} \sum_{j=1}^{n} \sum_{k \neq j}^{n} \E\left[x_{j} x_{k}\right] +\frac{1}{n^{2}} \sum_{j=1}^{n} \E\left[x_{j}^{2}\right] \right) \\ &= \frac{1}{n} \sum_{i=1}^{n} \left( \frac{n - 2}{n} \E\left[x_{i}^{2}\right] - \frac{2}{n} \sum_{j \neq i} \E\left[x_{i} x_{j}\right] + \frac{1}{n^2} \sum_{j=1}^{n} \sum_{k \neq j}^{n} \E\left[x_{j} x_{k}\right] +\frac{1}{n^2} \sum_{j=1}^{n} \E\left[x_{j}^{2}\right] \right) \\ &= \frac 1n \sum_{i=1}^{n} \left[ \frac{n - 2}{n} \left(\sigma^{2} + \mu^{2}\right) - \frac{2}{n} (n - 1)\mu^{2} + \frac{1}{n^{2}} n(n - 1)\mu^{2} + \frac{1}{n} \left(\sigma^{2} + \mu^{2}\right) \right] \\ &= \frac{n - 1}{n} \sigma^{2}. \end{aligned} \]

\(P\) valueをなぜ使うか

\[ \E\left[s^{2}_{B}\right]= \frac{n - 1}{n} \sigma^{2}. \] \(\frac{n}{n - 1}\)を乗じてバイアスを除去 \[ \frac{n}{n - 1}\E[s^{2}_{B}]=\sigma^{2} \Rightarrow \frac{n}{n - 1}\frac{1}{n}\sum_{i=1}^{n} (x_{i}-\bar{x})^{2}=\frac{1}{n - 1}\sum_{i=1}^{n} (x_{i}-\bar{x})^{2}. \]

  • \(n-1\)分の1×sseが母集団分散の不偏推計量(unbiased estimator)
  • \(n\)が十分に大きいと\(\frac{n}{n - 1}\simeq 1\)なので\(n\)分の1×sseでもあまり変わりない

不偏分散推計量\(s^{2}\)を母集団分散の推計値として使う

\[ s^{2}=\frac{1}{n - 1}\sum_{i=1}^{n} (x_{i}-\bar{x})^{2}. \]

\(P\) valueをなぜ使うか

ある程度大きな標本サイズ\(n\)でないと中心極限定理central limit theoremは使えない

標本サイズ\(n\)が小さい+正規分布に従うとき=\(t\)分布を使う

  1. 正規分布\(N(\mu, \sigma^{2})\)から無作為抽出された\(x_{i}\)
    • 小さな\(n\)でも抽出回数を無限大にするにつれて\(\bar{x}\)は正規分布に従う\[\frac{\bar{x}-\mu}{\frac{\sigma}{\sqrt{n}}} \quad \sim \quad N(0, 1)\]
  2. 母集団標準偏差←標本標準偏差\(s\)で代替 ⇒ \(t\)分布になる \[ \begin{aligned}\frac{\bar{x}-\mu}{\frac{s}{\sqrt{n}}}=\frac{\sqrt{n}(\bar{x}-\mu)/\sigma}{\sqrt{\frac{s^{2}}{\sigma^{2}}}} \quad \sim \quad \frac{N(0, 1)}{\sqrt{\frac{\chi^{2}(n-1)}{n-1}}}&=t_{n-1} \quad \scriptsize{\mbox{[$t$ distribution with $n-1$ degrees of freedom]}} \\ & s^{2}=\frac{1}{n-1}\sum_{i=1}^{n}(x_{i}-\bar{x})^{2}.\end{aligned} \]

References